
const mongoose = require('mongoose')
// 创建模式对象 引入模式对象
const Schema = mongoose.Schema
// 设计集合的约束
let user = new Schema({
	phone:{
		type:String,
		unique:true,//唯一
	},
	name:{
		type:String,
		required:true
	},
	psd:{
		type:String,
		required:true
	}
})

const registerSchema = new Schema({
    name:String,
    password:String,
    phone:String
})

// 生成集合，创建模式对象
let userModel = mongoose.model('user',user)
// 创建一条测试数据
userModel.findOne({},(err,data)=>{
	if(!data){
		userModel.create({
			name:'三九',
			phone:'17878270991',
			psd:'1234567'
		})
	}
})

module.exports = userModel